package com.yfp.machine.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.log.annotation.Log;
import com.yfp.common.log.enums.BusinessType;
import com.yfp.machine.domain.MachineRoad;
import com.yfp.machine.service.MachineRoadService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * (MachineRoad)表控制层
 *
 *
 * @since 2023-12-14 14:32:00
 */
@Tag(name = "货道信息相关")
@RestController
@RequestMapping("machineRoad")
public class MachineRoadController {
    /**
     * 服务对象
     */
    @Resource
    private MachineRoadService machineRoadService;

    @Operation(summary = "根据设备id获取货道信息")
    @GetMapping("/" +
            "" +
            "roadList/{machineId}")
    public R roadList(@Valid @PathVariable String machineId) {
        return R.ok(this.machineRoadService.getRoadList(machineId));
    }


    @Operation(summary = "设备货道库存修改")
    @Log(title = "设备货道库存修改", businessType = BusinessType.UPDATE)
    @PostMapping("inventory")
    public R inventoryModify(@RequestBody List<MachineRoad> machineRoads) {
        return this.machineRoadService.inventoryModify(machineRoads) ? R.ok() : R.fail();
    }
}

